﻿@{
    Layout = "~/Views/Shared/_FormGray.cshtml";
}

<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        <br /><br /><br /><br /><br /><br />
        <div class="form-group">
            <label class="col-sm-2 control-label ">DEV: </label>
            <div class="col-sm-9">
                <a class="btn btn-primary" href="tel:18337912510">+1 833-791-2510</a>
            </div>
        </div>

        @*<div class="form-group">
            <label class="col-sm-2 control-label ">QA:</label>
            <div class="col-sm-9">
                <a class="btn btn-primary" href="tel:16788550204">+1 678-855-0204</a>

            </div>
        </div>*@
        <div class="form-group">
            <label class="col-sm-2 control-label ">PROD:</label>
            <div class="col-sm-9">
                <a class="btn btn-primary" href="tel:18669310693">+1 866-931-0693</a>

            </div>
        </div>


    </form>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    $(function () {
        //getForm();
        //$("#callPlatform").select2({
        //    tags: true,
        //    createTag: function (params) {
        //        return {
        //            id: params.term,
        //            text: params.term,
        //            newOption: true
        //        }
        //    },
        //    templateResult: function (data) {
        //        var $result = $("<span></span>");

        //        $result.text(data.text);

        //        if (data.newOption) {
        //            $result.append(" <em>(new)</em>");
        //        }

        //        return $result;
        //    }
        //});
        $('#form').validate({
            rules: {
                callPlatform: { required: true },
                telephone: { required: true },
                consumerName: { required: true},
                telephonePrefix: { required: true },
            }
        });
        $("#btnSend").click(saveForm);
    });

    function getForm() {
        if (id > 0) {
            ys.ajax({
                url: '@Url.Content("~/BusinessManage/PhoneNumber/GetFormJson")' + '?id=' + id,
                type: 'get',
                success: function (obj) {
                    if (obj.Tag == 1) {
                        $('#form').setWebControls(obj.Data);
                    }
                }
            });
        }
        else {
            var defaultData = {};
            $('#form').setWebControls(defaultData);
        }
    }

    function saveForm(index) {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls({ Id: id });
            postData.telephonePrefix = $("#telephonePrefix").select2("val");
            postData.callPlatform = $("#callPlatform").select2("val");
            ys.ajax({
                url: '@Url.Content("~/BusinessManage/PhoneNumber/SendOutboundCall")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.Tag == 1) {
                        ys.msgSuccess(obj.Message);
                        //parent.searchGrid();
                        //parent.layer.close(index);
                    }
                    else {
                        ys.msgError(obj.Message);
                    }
                }
            });
        }
    }
</script>

